set(CMAKE_FOLDER "Scripting")

set(MODULE_ENTRY_FILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/module_entry.cpp.in)

function(AddScriptModule Target MODULE_NAME MODULE_LANG MODULE_DESC HotReloadSupport)

  if (${HotReloadSupport})
    set(HOT_RELOAD_SUPPORT 1)
  else()
    set(HOT_RELOAD_SUPPORT 0)
  endif()

  get_target_property(BIN_DIR ${Target} BINARY_DIR)
  configure_file(${MODULE_ENTRY_FILE_TEMPLATE} ${BIN_DIR}/module_entry.cpp)
  target_sources(${Target} PRIVATE ${BIN_DIR}/module_entry.cpp)
  target_link_libraries(${Target} PRIVATE DiaryCore)

  unset(HOT_RELOAD_SUPPORT)

  # 固定输出位置
  set_target_properties(
    ${Target} PROPERTIES
    PREFIX ""
    DEBUG_POSTFIX ""
    SUFFIX ".sm"
    LIBRARY_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:DiaryCore>/scripting
  )

endfunction()

add_subdirectory(wren)
add_subdirectory(quirrel)
add_subdirectory(angelscript)
add_subdirectory(python)
add_subdirectory(lua)
# add_subdirectory(js)
